package morenoapp.model.impl;

import com.jgoodies.binding.beans.Model;
import java.io.Serializable;
import morenoapp.model.data.MorenoIdFace;

/**
 * Базовый класс для всех элементов модели.
 *
 * @author dmitry.mamonov
 */
abstract class MorenoModelObject extends Model implements MorenoIdFace, Cloneable, Serializable {
    private static final long serialVersionUID = -9016363588144417003L;

    private long id;
    private MorenoModelImpl model;

    protected MorenoModelObject(MorenoModelImpl model) {
        super();
        this.model = model;
        this.id = model.nextId();
    }

    protected MorenoModelImpl getModel() {
        return model;
    }

    @Override
    public long getId() {
        return this.id;
    }

    @Override
    public void setId(long id){
        long oldId = this.id;
        this.id = id;
        this.firePropertyChange("id", oldId, this.id);
    }

    protected static void checkNotNull(Object argument){
        if(argument==null){
            throw new IllegalArgumentException("Argument must not be null"); //NOI18N
        }
    }
}
